<template>
  <div @mouseenter="mouseIn" @mouseleave="mouseOut" :class="{ focus: isFocus }">
    <el-card style="max-width: 260px;padding: 3% !important;">
      <el-image class="elImage" :src="sPath" @click="handleClickPicture">
      </el-image>
      <div>
        <el-row :gutter="10" type="flex" justify="space-around">
          <el-col :span="4">
            <el-popover placement="right" width="300" trigger="hover">
              <el-descriptions title="资源详情" :column="2" border transition>
                <el-descriptions-item label="资源ID">{{
                  sId
                }}</el-descriptions-item>
                <el-descriptions-item label="更新时间">{{
                  sUpdateTime
                }}</el-descriptions-item>
                <el-descriptions-item label="路径">{{
                  sPath
                }}</el-descriptions-item>
              </el-descriptions>
              <i class="el-icon-info pictureCardInfo" slot="reference"></i>
            </el-popover>
          </el-col>
          <el-col :span="16">
            <h5 class="picname">{{ sName }}</h5>
          </el-col>
          <el-col :span="4" style="padding-left: 10px">
            <i
              class="el-icon-circle-close pictureCardRemove"
              style="text-align: right"
              @click="handlepictureCardRemoveClick"
            ></i>
          </el-col>
        </el-row>
      </div>
    </el-card>
  </div>
</template>
  <script>
import { fileSiteUrl } from "@/api/constTools";
// import { log } from "console";
export default {
  name: "PictureCard",
  data() {
    return {
      // 此处所有的数据应该是从上级组件中传回来的
      sId: 0,
      sPath: "",
      sUpdateTime: "",
      sName: "",

      srcList: [],
      isFocus: false,
      BaseApiUrl: fileSiteUrl,
    };
  },
  computed: {
    // url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    //   srcList: [
    //     "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    //     "https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg",
    //   ],
    //   name:"这里是图片名称"
  },
  methods: {
    initSrcData() {
      // let that=this;

      this.sId = this.data.sId;
      this.sPath = this.BaseApiUrl + this.data.sPath;
      this.sUpdateTime = this.data.sUpdateTime;
      this.sName = this.data.sName;

      // this.srcList = [];
      // this.srcList.push(this.sPath);
    },
    mouseIn() {
      //   console.log("mouse in");
      // 鼠标移入时，改变当前项样式
      // console.log(this.$refs["imageCard"]);
      this.isFocus = true;
    },
    mouseOut() {
      //   console.log("mouse out");
      this.isFocus = false;
    },
    handlepictureCardRemoveClick() {
      // this.$message.info("点击了");
      // console.log(this.BaseApiUrl);
      // console.log(BaseApiUrl);
      this.$emit("deleteSingleSource",this.sId);
    },
    handleClickPicture() {
      // 将子组件中的信息传回父组件
      // console.log("111");
      this.$emit("handlePreview", this.sPath);
    },
  },
  props: ["data"],
  mounted() {
    this.initSrcData();
    // console.log(this.BaseApiUrl);
  },
};
</script>
<style scoped>
.el-card__body {
  padding: 10px !important;
}
.focus {
  transform: scale(1.1);
}
.picname {
  margin: 0% !important;
  text-align: center;
  white-space: nowrap;
  /* 2.溢出的部分隐藏起来 */
  overflow: hidden;
  /* 3.文字溢出的时候用省略号来显示 */
  text-overflow: ellipsis;
}
.pictureCardInfo:hover,
.pictureCardRemove:hover {
  color: red;
}
.elImage {
  max-height: 120px !important;
}
.elImage > img {
  width: 92% !important;
  min-width: 185px;
}
</style>